package com.tiancheng.onecode.utils;

import com.fasterxml.jackson.core.type.TypeReference;
import com.tiancheng.onecode.configuration.auth.StpKit;
import com.tiancheng.onecode.exception.Asserts;
import com.tiancheng.onecode.model.dto.MemberLoginInfoDTO;
import lombok.extern.slf4j.Slf4j;

import java.util.Objects;

/**
 * @ClassName MemberUtils
 * @Description: 会员工具类
 * @Author kellen
 * @Date 2024/12/14 20:58
 */
@Slf4j
public class MemberUtils {
    public static MemberLoginInfoDTO getMemberInfo(){
        Object memberInfo = StpKit.mini.getExtra("memberInfo");
        if(Objects.nonNull(memberInfo)){
            return JsonUtil.fromJson(memberInfo, new TypeReference<MemberLoginInfoDTO>() {
            });
        }
        Asserts.fail("请登录！");
        return null;
    }
}
